
clear

cd "D:\data_replication"

import delimited estimation\4_demand_estimation\pc8plus_i_k.csv, clear 
keep v1 v3
rename v1 product_id
rename v3 k
save estimation\4_demand_estimation\4_cobb_douglas_weights\pc8plus_i_k_gini.dta, replace


use estimation\4_demand_estimation\4_cobb_douglas_weights\weights_product_id_gini.dta, clear
merge m:1 product_id using estimation\4_demand_estimation\4_cobb_douglas_weights\pc8plus_i_k_gini.dta
keep k year quarter declarant s_1_product_id-s_100_product_id
drop if k == 0
drop if k == .
order k year quarter declarant 
sort k year quarter declarant
forval i = 1/100 {
rename s_`i'_product_id s_`i'_k
}
save estimation\4_demand_estimation\4_cobb_douglas_weights\weights_k_gini.dta, replace
export delimited using estimation\4_demand_estimation\4_cobb_douglas_weights\weights_k_gini.csv, replace

rm estimation\4_demand_estimation\4_cobb_douglas_weights\pc8plus_i_k_gini.dta

